/*
 * $Id: memory.h,v 1.11 2005-07-27 15:57:08 bacon Exp $
 */

#ifndef _XP_BAS_MEMORY_H_
#define _XP_BAS_MEMORY_H_

#include <xp/types.h>
#include <xp/macros.h>

#include <stdlib.h> 
#define xp_malloc  malloc
#define xp_free    free
#define xp_realloc realloc
#define xp_calloc  calloc    

#ifdef __cplusplus
extern "C" {
#endif

void* xp_memcpy_i  (void* dst, const void* src, xp_size_t n);
void* xp_memmove_i (void* dst, const void* src, xp_size_t n);
void* xp_memset_i  (void* dst, int byte, xp_size_t n);
int   xp_memcmp_i  (const void* s1, const void* s2, xp_size_t n);
void* xp_memchr_i  (const void* s, int byte, xp_size_t n);
void* xp_memrchr_i (const void* s, int byte, xp_size_t n);
void* xp_memmem (
	const void* haystack, xp_size_t hsz, const void* needle, xp_size_t nsz);
xp_size_t xp_swab (void* dst, const void* src, xp_size_t n);

#ifdef __cplusplus
}
#endif

/*
#if defined(XP_USE_STOCK_FUNCTIONS)
*/
	#include <string.h>
	#define xp_memcpy   memcpy
	#define xp_memmove  memmove
	#define xp_memset   memset
	#define xp_memcmp   memcmp
	#define xp_memchr   memchr
/*
#else
	#define xp_memcpy   xp_memcpy_i
	#define xp_memmove  xp_memmove_i
	#define xp_memset   xp_memset_i
	#define xp_memcmp   xp_memcmp_i
	#define xp_memchr   xp_memchr_i
#endif
*/

#define xp_memrchr xp_memrchr_i

#endif
